package com.example.caoben_back.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.caoben_back.entity.po.Post;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 存储论坛帖子信息 Mapper 接口
 * </p>
 *
 * @author ylsink
 * @since 2025-11-05
 */
public interface PostMapper extends BaseMapper<Post> {
    
    /**
     * 查询热门帖子
     * @param offset 偏移量
     * @param limit 限制数量
     * @return 热门帖子列表
     */
    @Select("SELECT * FROM post ORDER BY (like_count * 0.3 + reply_count * 0.7) DESC LIMIT #{offset}, #{limit}")
    List<Post> selectHotPosts(@Param("offset") int offset, @Param("limit") int limit);
}